<?php require_once('../connections/con_gl.php'); ?>
<?php
$getquery = str_replace("+"," ",$_GET[query]);
$getquerykorporate = str_replace("+"," ",$_GET[query_korporate]);
mysql_select_db($database_con_gl, $con_gl);
$query_rtrans = stripslashes($getquery);
$rtrans = mysql_query($query_rtrans, $con_gl) or die(mysql_error());
$row_rtrans = mysql_fetch_assoc($rtrans);
$totalRows_rtrans = mysql_num_rows($rtrans);
$mulai = $_GET['mulai'];
$akhir = $_GET['akhir'];    
	
mysql_select_db($database_con_gl, $con_gl);
$query_datakorporate = $getquerykorporate;
$cekdatakorporate= mysql_query($query_datakorporate, $con_gl) or die(mysql_error());
$row_datakorporate = mysql_fetch_assoc($cekdatakorporate);
$totalRows_korporate = mysql_num_rows($cekdatakorporate);

mysql_select_db($database_con_gl, $con_gl);
$query_data = $getquery;
$cekdata= mysql_query($query_data, $con_gl) or die(mysql_error());
$row_data = mysql_fetch_assoc($cekdata);
$totalRows_cekbrg = mysql_num_rows($cekdata);

mysql_select_db($database_con_gl, $con_gl);
$query_getcompany = "SELECT * FROM gl_company WHERE id = 1";
$getcompany = mysql_query($query_getcompany, $con_gl) or die(mysql_error());
$row_getcompany = mysql_fetch_assoc($getcompany);
$totalRows_getcompany = mysql_num_rows($getcompany);
?>
<style type="text/css">
<!--
.style2 {font-size: 18px}
-->
</style>

<P align="center"><span class="style2"><strong>CIPAGANTI RENTAL CAR & TRAVEL</strong></span></P>
<P align="center" class="style2"><strong>REKAPITULASI UMUR PIUTANG DAGANG</strong></P>
<br />
<p align="left"></P>
<p align="left">&nbsp;</P>
<table width="103%" border="0" cellpadding="4" cellspacing="0" bordercolor="#000000">
<th align="left" width="200">CABANG : <?php echo $row_data['gudang']; ?></th>
  <th width="100">&nbsp;</th>
  <th width="100">&nbsp;</th>
  <th width="100">&nbsp;</th>
  <th width="100">&nbsp;</th>
  <th width="100" align="center"></th>
  <th width="100" align="center">PERIODE : <?php echo $mulai.'-'.$akhir ?></th>
</table>
<table width="100%" border="1" cellpadding="4" cellspacing="0" bordercolor="#000000">
<tr bgcolor="#CCCCCC">
        <th width="200">Customer</th>
        <th width="100"><strong>0 -30 hari</strong></th>
        <th width="100"><strong>31 - 60 hari</strong></th>
        <th width="100">61 - 90 hari</th>
        <th width="100">91 - 120 hari</th>
        <th width="100">Lebih dari 120 hari</th>
        <th width="100" align="center"><strong>Total</strong></th>
    </tr>
	
	


        <tr valign="top">
          <td colspan="7" align="left"><strong>SEWA KENDARAAN RETAIL</strong></td>
        </tr>
       <?php do { ?>
        <tr valign="top">
          <td align="left"><strong><?php echo $row_data['nama'];?></strong></br><?php echo $row_data['alamat'];?></td>
          <td align="right"><?php echo number_format($row_data['satu'],0,',','.').",-";?></td>
          <td align="right"><?php echo number_format($row_data['dua'],0,',','.').",-"; ?></td>
          <td align="right"><?php echo number_format($row_data['tiga'],0,',','.').",-"; ?></td>
          <td align="right"><?php echo number_format($row_data['empat'],0,',','.').",-"; ?></td>
          <td align="right"><?php echo number_format($row_data['lima'],0,',','.').",-"; ?></td>
          <td align="right"><?php echo number_format($row_data['satu'] + $row_data['dua'] + $row_data['tiga'] + $row_data['empat']+$row_data['lima'],0,',','.').",-"; ?></td>
        </tr>
			<?php 
        $totalsatu += $row_data['satu'];
        $totaldua += $row_data['dua'];
        $totaltiga += $row_data['tiga'];
		$totalempat += $row_data['empat'];
        $totallima += $row_data['totalbayar'];
        $totalretail += $row_data['satu'] + $row_data['dua'] + $row_data['tiga'] + $row_data['empat']+$row_data['lima'];
        } while ($row_data = mysql_fetch_assoc($cekdata)); ?>
        <tr valign="top">
          <td align="right"><span style="font-weight: bold">SUB TOTAL :</span></td>
          <td align="right"><strong><?php echo number_format($totalsatu,0,',','.').",-";?></strong></td>
          <td align="right"><strong><?php echo number_format($totaldua,0,',','.').",-";?></strong></td>
          <td align="right"><strong><?php echo number_format($totaltiga,0,',','.').",-";?></strong></td>
          <td align="right"><strong><?php echo number_format($totalempat,0,',','.').",-";?></strong></td>
          <td align="right"><strong><?php echo number_format($totallima,0,',','.').",-";?></strong></td>
          <td align="right"><strong><?php echo number_format($totalretail,0,',','.').",-";?></strong></td>
        </tr>
        
        <tr valign="top">
          <td colspan="7" align="left"><strong>SEWA KENDARAAN NON RETAIL</strong></td>
        </tr>
  <?php do { ?>
    <tr valign="top">
      <td align="left"><strong><?php echo $row_datakorporate['nama'];?></strong></br>
      <?php echo $row_datakorporate['alamat'];?></td>
	  <td height="47" align="center"><?php echo number_format($row_datakorporate['satu'],0,',','.').",-";?></td>
      <td align="center"></a><?php echo number_format($row_datakorporate['dua'],0,',','.').",-"; ?></td>
      <td align="center"><?php echo number_format($row_datakorporate['tiga'],0,',','.').",-"; ?></td>
      <td align="center"><?php echo number_format($row_datakorporate['empat'],0,',','.').",-"; ?></td>
      <td align="center"><?php echo number_format($row_datakorporate['lima'],0,',','.').",-"; ?></td>
      <td align="right"><?php echo number_format($row_datakorporate['satu'] + $row_datakorporate['dua'] + $row_datakorporate['tiga'] + $row_datakorporate['empat']+$row_datakorporate['lima'],0,',','.').",-"; ?></td>
    </tr>
	<?php 
        $totalsatukorporate += $row_datakorporate['satu'];
        $totalduakorporate += $row_datakorporate['dua'];
        $totaltigakorporate += $row_datakorporate['tiga'];
		$totalempatkorporate += $row_datakorporate['empat'];
        $totallimakorporate += $row_datakorporate['totalbayar'];
        $totalkorporate += $row_datakorporate['satu'] + $row_datakorporate['dua'] + $row_datakorporate['tiga'] + $row_datakorporate['empat']+$row_datakorporate['lima'];
        } while ($row_datakorporate = mysql_fetch_assoc($cekdatakorporate)); ?>
    <tr valign="top">
      <td align="center"><strong>SUBTOTAL</strong></td>
      <td align="right"><strong><?php echo number_format($totalsatukorporate,0,',','.').",-";?></strong></td>
      <td align="right"><strong><?php echo number_format($totalduakorporate,0,',','.').",-";?></strong></td>
      <td align="right"><strong><?php echo number_format($totaltigakorporate,0,',','.').",-";?></strong></td>
      <td align="right"><strong><?php echo number_format($totalempatkorporate,0,',','.').",-";?></strong></td>
      <td align="right"><strong><?php echo number_format($totallimakorporate,0,',','.').",-";?></strong></td>
      <td align="right"><strong><?php echo number_format($totalkorporate,0,',','.').",-";?></strong></td>
  </tr>   
<tr valign="top">
      <td align="center"><strong>GRAND TOTAL</strong></td>
      <td align="center">&nbsp;</td>
      <td align="center">&nbsp;</td>
      <td align="center">&nbsp;</td>
      <td align="center">&nbsp;</td>
      <td align="center">&nbsp;</td>
      <td align="right"><strong><?php echo number_format($totalretail+$totalkorporate,0,',','.').",-";?></strong></td>
  </tr>
</table>
  
  
